home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Format / asn / asn_dec.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  1.2 KB  |  84 lines

  1. /* asn_dec.c - decode ASN after reading from stdin */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Format/asn/RCS/asn_dec.c,v 6.0 1991/12/18 20:15:43 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Format/asn/RCS/asn_dec.c,v 6.0 1991/12/18 20:15:43 jpo Rel $
  9.  *
  10.  * $Log: asn_dec.c,v $
  11.  * Revision 6.0  1991/12/18  20:15:43  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include    "head.h"
  19. #include    "asn.h"
  20.  
  21. #define SLEN    128
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29. /* ------------------------  Start Routine  --------------------------------- */
  30.  
  31.  
  32.  
  33.  
  34. asn_decode(func_decode, data)
  35. int    (*func_decode) ();
  36. ASNBODY    **data;
  37. {
  38.     int        retval;
  39.  
  40.     PP_TRACE (("asn_decode()"));
  41.  
  42.     /* --- *** ---
  43.     get body part from stdin this can be plain or wrapped
  44.     if ffunc is set then it is wrapped.
  45.     --- *** --- */
  46.  
  47.     if (func_decode == NULL) {
  48.         rd_stdin (data);    
  49.         return;
  50.     }
  51.  
  52.     retval = (*func_decode)(data);
  53. }
  54.  
  55.  
  56.  
  57.  
  58. /* ------------------------  Static Routines  ------------------------------- */
  59.  
  60.  
  61.  
  62.  
  63. static rd_stdin (data)
  64. ASNBODY        **data;
  65. {
  66.     int    len;
  67.     char    *buf;
  68.  
  69.     PP_TRACE (("rd_stdin()"));
  70.  
  71.     buf = smalloc (SLEN);
  72.     bzero (buf, SLEN);
  73.  
  74.     while ((len = read (0, buf, SLEN)) > 0) {
  75.         buf[len] = '\0';
  76.         asnbody_add (data, buf, len);
  77.  
  78.         buf = smalloc (SLEN);
  79.         bzero (buf, SLEN);
  80.     }    
  81.  
  82.     free (buf);
  83. }
  84.